$(function(){
	$(".user-logo").on("click",function(){
		$(".message-float").toggleClass("float-down");	
		$(".message-holder").toggleClass("active");
	});

	var emailTitle='更换邮箱';
	var emailHtml=
    '<div class="input-header">请输入新的邮箱号</div>'
    + '<input type="text" placeholder="请输入新的邮箱号" class="alert-input-b alert-w1"/>'
    + '<input type="button" class="button-green" value="发送邮件"/>'
    + '<span class="beizhu">我们将发送一封确认邮件到您的邮箱，请点击验证链接进行验证</span>';
	
	var passwordTitle='修改密码';
    var passwordHtml=
    '<div class="input-header">请输入原密码</div>'
    + '<input type="password" placeholder="请输入原密码" class="alert-input-b alert-w1"/>'
    + '<div class="input-header">请输入新密码</div>'
    + '<input type="password" placeholder="请输入新密码" class="alert-input-b alert-w1"/>'
    + '<input type="button" class="button-green" value="确定"/>';

	var mobileTitle='更换手机号码';
	var mobileHtml=
    '<div class="input-header">请输入新的手机号码</div>'
    + '<input type="text" placeholder="请输入新的手机号码" class="alert-input-b alert-w1"/>'
    + '<input type="button" class="button-green" value="获取验证码"/>'
    + '<div class="input-header">请输入验证码</div>'
    + '<input type="text" class="alert-input-b alert-w2"/>';

	//var imgHtml='<form id="upload_portrait_form" enctype="multipart/form-data" method="post" action="AppWebIndex">'
	var imgHtml=
    '<form id="upload_portrait_form" enctype="multipart/form-data" method="post">'
        +'<div class="alert-float-holder">'
            +'<div class="alert-info-left">'
                +'<div class="input-header">新的头像</div>'
	            +'<div id="standardDiv" style="width:100px;height: 100px;display: none;"></div>'
	            //+'<button class="button-green" id="triggerFile">点击选择头像</button>'
	            +'<input class="button-green" name="fileInput" id="fileInput" type="file" style="display: block;padding-top: 8px;" />'
	            +'<span class="beizhu" style="display: inline-block; margin-left: 10px;">图片文件最大5MB，支持.jpg的图片格式</span>'
	            +'<div class="input-header">编辑并预览图片</div>'
            +'</div>'
	        +'<div class="alert-info-right">'
                +'<div class="input-header">当前头像：</div>'
	            +'<img src="'+$(".user-logo").attr("src")+'" class="alert-preview-img" />'
            +'</div>'
        +'</div>'
	    +'<div class="alert-float-holder">'
            +'<div id="targetCon" class="img-float-l">'
	            +'<img src="" id="target" />'
                //+'<div id="imgFloatm" class="img-float-m">'
                //    +'<div class="preview-m-con">'
	            //        +'<img src="" />'
                //    +'</div>'
                //+'</div>'
                //+'<div class="img-float-r">'
                //    +'<div class="preview-r-con">'
	            //        +'<img id="targetR" src="" />'
                //    +'</div>'
                //+'</div>'
            +'</div>'
            +'<div class="img-float-mr">'
	            //+'<div class="input-header" style="margin-top:80px;">其他两个尺寸头像</div>'
	            +'<div class="input-header" style="margin-top:80px;"></div>'
	            +'<button id="portraitUpload" class="button-green" style="display: block; float: left; margin-top: 45px;margin-left: 350px;position:" onclick="PortraitUploading()">保存</button>'
            +'</div>'
        +'</div>'
    +'</form>';
	var imgTitle="修改头像";
	
	$("#userImg").click(function(){
		alertMsg(imgHtml,'2',imgTitle,"",320);
	});
	$("#emailIcon").click(function(){
		alertMsg(emailHtml,'2',emailTitle,"",150);
	});
	$("#phoneIcon").click(function(){
		alertMsg(mobileHtml,'2',mobileTitle,"",150);
	});
	$("#passwordIcon").click(function(){
		alertMsg(passwordHtml,'2', passwordTitle,"",150);
	});
	$(".msg").on("click",function(){
		$(".msg-con").toggleClass("msg-up");
	});
    //$('body').delegate("#portraitUpload","click",function(){
    //    alert('aaa');
    //});
});

function PortraitUploading(){
    var vFD = new FormData(document.getElementById('upload_portrait_form')); 
    var oXHR = new XMLHttpRequest();
    oXHR.open('POST', 'AppWebPortraitEdit');
    oXHR.send(vFD);
}
